#pragma once

#include <d3dx9math.h>
#include <string>

const int width = 800;
const int height = 600;

namespace d3d
{
	// release template
	template<class T> void Release(T& t)
	{
		if(t)
		{
			t->Release();
			t = NULL;
		}
	}

	template<class T> void Delete(T& t)
	{
		if(t)
		{
			Delete t;
			t = NULL;
		}
	}

	// color
	const D3DXCOLOR WHITE(D3DCOLOR_XRGB(255,255,255));
	const D3DXCOLOR BLACK(D3DCOLOR_XRGB(0,0,0));
	const D3DXCOLOR RED(D3DCOLOR_XRGB(255,0,0));
	const D3DXCOLOR GREEN(D3DCOLOR_XRGB(0,255,0));
	const D3DXCOLOR BLUE(D3DCOLOR_XRGB(0,0,255));
	const D3DXCOLOR YELLOW(D3DCOLOR_XRGB(255,255,0));
	const D3DXCOLOR CYAN(D3DCOLOR_XRGB(0,255,255));
	const D3DXCOLOR MAGENTA(D3DCOLOR_XRGB(255,0,255));
	const D3DXCOLOR ORANGE(D3DCOLOR_XRGB(255,128,0));

	// material
	D3DMATERIAL9 InitMtrl(D3DXCOLOR a, D3DXCOLOR d, D3DXCOLOR s, D3DXCOLOR e, float p);

	const D3DMATERIAL9 WHITE_MTRL = InitMtrl(WHITE,WHITE,WHITE,BLACK,8.0f);
	const D3DMATERIAL9 RED_MTRL = InitMtrl(RED,RED,RED,BLACK,8.0f);
	const D3DMATERIAL9 GREEN_MTRL = InitMtrl(GREEN,GREEN,GREEN,BLACK,8.0f);
	const D3DMATERIAL9 BLUE_MTRL = InitMtrl(BLUE,BLUE,BLUE,BLACK,8.0f);
	const D3DMATERIAL9 YELLOW_MTRL = InitMtrl(YELLOW,YELLOW,YELLOW,BLACK,8.0f);
	const D3DMATERIAL9 CYAN_MTRL = InitMtrl(CYAN,CYAN,CYAN,BLACK,8.0f);
	const D3DMATERIAL9 ORANGE_MTRL = InitMtrl(ORANGE,ORANGE,ORANGE,BLACK,8.0f);

	// light
	D3DLIGHT9 InitDirectionalLight(D3DXVECTOR3 *direction, D3DXCOLOR *color);
	D3DLIGHT9 InitPointLight(D3DXVECTOR3 *position, D3DXCOLOR *color);
	D3DLIGHT9 InitSpotLight(D3DXVECTOR3 *position, D3DXVECTOR3 *direction, D3DXCOLOR *color);
}